#!/usr/local/bin/perl

push @INC, "$ENV{RMSCRIPTS}";
require "global.pl";                    # include global variables

$monoset=$ARGV[0];
$discretehmm=$ARGV[1];
$discretesp=$ARGV[2];

open (FILE, "<$monoset") or die ("Unable to open monophone file");
@monofile = <FILE>;
foreach $mono (@monofile) {
	if ($mono ne "sp\n") {
		open (FILE_HMM, ">>hmm0\\$mono");
		print FILE_HMM "~o <VecSize> 39 <MFCC_E_D_A_V> <StreamInfo> 4 12 12 12 3\n";
		print FILE_HMM "~h $mono\n";
		open (FILE_SRC, "<$discretehmm");
		@srcdata = <FILE_SRC>;
		foreach $src (@srcdata) {
			print FILE_HMM $src;
		}
		close(FILE_SRC);
		close(FILE_HMM);
	}
}
close(monofile);

open (FILE_HMM, ">>hmm0\\sp");
print FILE_HMM "~o <VecSize> 39 <MFCC_E_D_A_V> <StreamInfo> 4 12 12 12 3\n";
print FILE_HMM "~h sp\n";
open (FILE_SP, "<$discretesp");
@spdata = <FILE_SP>;
foreach $sp (@spdata) {
	print FILE_HMM $sp;
}
close(FILE_SP);
close(FILE_HMM);
